package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.BeautyCare;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 美容护理表 Mapper 接口
 * </p>
 *
 * @author Mr.Xiayh
 * @since 2024-06-03
 */
@Mapper
public interface BeautyCareMapper extends BaseMapper<BeautyCare> {
    /**
     * 根据ID查询
     * @param bcId
     * @return
     */
    @Select("SELECT * FROM beauty_care WHERE bc_id = #{bcId} AND flag = 1")
    public BeautyCare selectBeautyCareByBcId(Integer bcId);

    @Insert("INSERT INTO beauty_care(work_name,create_time) values(#{workName},now())")
    int addBeautyCare(BeautyCare beautyCare);

    /**
     * 根据员工ID查询
     * @param workersId
     * @return
     */
    @Select("SELECT * FROM beauty_care t1\n" +
            "INNER JOIN workers_and_bc t2\n" +
            "ON t2.bc_id = t1.bc_id\n" +
            "WHERE t2.workers_id = #{workersId}")
    BeautyCare selectByWorkersId(Integer workersId);

    /**
     *  查询所有美容护理信息
     * @return
     */
    @Select("SELECT * FROM beauty_care")
    List<BeautyCare> selectBeautyCareAll();

    /**
     * 根据id删除美容护理信息
      */
    @Delete("Delete FROM beauty_care WHERE bc_id = #{bcId}")
    int deleteBeautyCareById(Integer bcId);
}
